mysql -uroot -proot -hhadoop2<<EOF
use sqlserver;

DELETE from transactions where transaction_date>='2019-02';
DELETE from transaction_items_oil where transaction_date>='2019-02';
DELETE from transaction_items_notoil where transaction_date>='2019-02';
DELETE from transaction_items_cashbox where transaction_date>='2019-02';
DELETE from transaction_items_mop where transaction_date>='2019-02';
DELETE from transaction_period where transaction_date>='2019-02';

-- UPDATE transaction_items set transaction_date=
-- (SELECT b.transaction_db_date from transactions as b where transaction_items.transaction_id=b.transaction_id
-- and transaction_items.station_id=b.station_id and transaction_items.transaction_date=b.transaction_date);

UPDATE transaction_items_cashbox set transaction_date=
(SELECT b.transaction_date from transactions as b where transaction_items_cashbox.transaction_id=b.transaction_id
and transaction_items_cashbox.station_id=b.station_id and transaction_items_cashbox.transaction_date=b.transaction_date);

UPDATE transaction_items_mop set transaction_date=
(SELECT b.transaction_date from transactions as b where transaction_items_mop.transaction_id=b.transaction_id
and transaction_items_mop.station_id=b.station_id and transaction_items_mop.transaction_date=b.transaction_date);


UPDATE transaction_items_notoil set transaction_date=
(SELECT b.transaction_date from transactions as b where transaction_items_notoil.transaction_id=b.transaction_id
and transaction_items_notoil.station_id=b.station_id and transaction_items_notoil.transaction_date=b.transaction_date);


UPDATE transaction_items_oil set transaction_date=
(SELECT b.transaction_date from transactions as b where transaction_items_oil.transaction_id=b.transaction_id
and transaction_items_oil.station_id=b.station_id and transaction_items_oil.transaction_date=b.transaction_date);


UPDATE transaction_period set transaction_date=
(SELECT b.transaction_date from transactions as b where transaction_period.transaction_id=b.transaction_id
and transaction_period.station_id=b.station_id and transaction_period.transaction_date=b.transaction_date);



EOF